Practice Set 6
We'll cover the following
Practice Set 6#
For the purpose of demonstrating analytic window functions, we added a new MoviesScreening table and added some columns to the existing Movies table. The relevant portion of the database relationship model is printed below.
Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/quiz2.sh and wait for the MySQL prompt to start-up.
Write and execute queries for the following questions:
-
Find the top two movies of distributors who have more than one movie to their name.
Expected Result:
Distributor | Movie | CollectionInMillion | Rank |
---|---|---|---|
Paramount Pictures | … | … | 1 |
Paramount Pictures | … | … | 2 |
Warner Bros | … | … | 1 |
Warner Bros | … | … | 2 |
-
Find the total, average, minimum and maximum of the production budget and revenue earned from the Movies table and append the summary data to the top of the table.
Expected Result:
Name | BudgetInMillions | CollectionInMillions |
---|---|---|
Total | … | … |
Average | … | … |
Maximum | … | … |
Minimum | … | … |
Ocean’s Twelve | … | … |
Mission Impossible | … | … |
… | … | … |
-
Calculate the mean median and mode of the running time of movies.
Expected Result:
Measure | Value |
---|---|
Mean | … |
Median | … |
Mode | … |
-
Find the correlation between budget, collection and running time of movies and display the results as a table.
Expected Result:
BudgetInMillions | CollectionInMillions | RunningTime | |
---|---|---|---|
BudgetInMillions | 1.00 | … | … |
CollectionInMillions | … | 1.00 | … |
RunningTime | … | … | 1.00 |
-
Find the market share of top 3 distributors and aggregate the remaining distributors in a single row.
Expected Result:
Distibtor | TotalCollection |
---|---|
distributor 1 | amount |
distributor 2 | amount |
distributor 3 | amount |
All Others | amount |